import unittest
from parameterized import parameterized

from api.manage_install_record_api import ManageInstallRecord
from common.assertUtil import assertUtil

from common.read_data import read_manage_install_record, read_install_record_delete, read_install_record_update


class TestManageInstallRecord(unittest.TestCase):
    #添加安装记录
    @parameterized.expand(read_manage_install_record())
    @unittest.skip
    def test_add(self,desc,req_data,success,msg):
        resp = ManageInstallRecord.record_add(req_data)
        assertUtil(self,resp,success,msg)

    # 查询所有
    @unittest.skip
    def test_select_all(self):
        req_data = {
                        "createTimeBegin": "",
                        "createTimeEnd": "",
                        "id": "",
                        "installationLocation": "",
                        "installationStatus":"" ,
                        "installationTime": "",
                        "orderId": "",
                        "orders": [
                            {
                                "asc": True,
                                "column": ""
                            }
                        ],
                        "pageNum": 1,
                        "pageSize": 10,
                        "regionCode": "",
                        "searchCount": False,
                        "serviceMan": 0,
                        "serviceStoreId": 0,
                        "updateTimeBegin": "",
                        "updateTimeEnd": ""
                    }
        resp = ManageInstallRecord.select_install_all(req_data)
        assertUtil(self, resp, True, "操作成功")

    #通过ID删除安装记录
    @parameterized.expand(read_install_record_delete())
    @unittest.skip
    def test_delete_id(self, desc, userId, success, expect):
        try:
            resp = ManageInstallRecord.delete_install_uid(userId)
        except Exception as err:
            print(f"错误是：{err}")
        finally:
            assertUtil(self, resp, success, expect)

    #通过ID更新安装记录
    @parameterized.expand(read_install_record_update())
    #@unittest.skip
    def test_update_id(self, desc, req_data, success, expect):
        try:
            resp = ManageInstallRecord.update_install_record(req_data)
        except Exception as err:
            print(f"错误是：{err}")
        finally:
            assertUtil(self, resp, success, expect)
